/**
 * @file
 *           ComandsImpl.h
 * @brief
 *          <fillin>purpose
 *
 * @par Author (last changes):
 *          - Herea Adrian
 *
 * @par Description:
 *
 *
 * @par Module-History:
 * @verbatim
 *  Date        Author                          Reason
 *  15.01.2010  Herea Adrian         Initial creation
 *  23.01.2010  Herea Adrian         Change dir implementation finished
 *
 * @endverbatim
 *
 * @par Copyright Notice:
 * @verbatim
 * Copyright (C) 2010
 * All Rights Reserved.
 * The reproduction, transmission or use of this document or its contents is
 * not permitted without express written authority.
 * Offenders will be liable for damages. All rights, including rights created
 * by patent grant or registration of a utility model or design, are reserved.
 **/
#pragma once

#include "SocketServer.h"
#include "ReceiverListener.h"
#include "protocol.h"
#include "base64.h"
#include "DefineConst.h"
#include "FSOperations.h"
#include <vector>
#include <string>
#include <algorithm>

class ComandsImpl
{
public:
  ComandsImpl(void);
public:
  ~ComandsImpl(void);

  void
  sendServersAddress(SocketServer* m_sockServer);
  void
  sendChangeDirResult(SocketServer* m_sockServer, string path);
  void
  sendDirContent(SocketServer* m_sockServer, string path);
  void
  sendError(SocketServer* m_sockServer, string Errorcode);

  void
  setFsOperations(FSOperations * FSOperations)
  {
    m_FSOperations = FSOperations;
  }

	/**
	* Sends amount of free space to the client
	* @param m_sockServer Server socket
	*/
	void sendAvailableSpace(SocketServer* m_sockServer);

	/**
	* Creates the file on the server and sends the notification to the client
	* @param m_sockServer Server socket
	* @param path Path to the file name to be created
	*/
	void sendCreateNewFile(SocketServer* m_sockServer, std::string path);

	/**
	* Checks if a file already exists
	* @param m_sockServer Server socket
	* @param path Path to be checked
	*/
	void sendPathExists(SocketServer* m_sockServer, std::string path);

	/**
	* Creates the directory structure (path) on the server and sends the notification to the client
	* @param m_sockServer Server socket
	* @param path Directory structure to be created
	*/
	void sendCreateNewDir(SocketServer* m_sockServer, std::string path);

private:
  FSOperations * m_FSOperations;
	typedef std::vector<std::string> ServerList_t;

	static bool getServerListFromFile(char* filename, ServerList_t& outList);
};
